package com.ly;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;

/**
 * 单体启动类
 */
@Slf4j
@SpringBootApplication
public class SystemApp {

    public static void main(String[] args) throws UnknownHostException {
        SpringApplication app = new SpringApplication(SystemApp.class);
        app.setDefaultProperties(new HashMap<>() {{
            put("management.health.elasticsearch.enabled", false);
        }});
        ConfigurableApplicationContext application = app.run(args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        log.info("\nLocal: \t\thttp://localhost:" + port + path + "/doc.html\n" +
                "Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n");
    }
}